import http from "@/api";
import {
    AuthRequestModel,
    AuthModel,
    MenuPermissionsModel,
    MessageModel,
    RegisterRequestModel, PasswordRequestModel
} from "@/models/authModel";
import {LoggerModel, LoginLogModel, UserModel} from "@/models/settingModel.ts";
import {ResultData, ResultPage} from "@/api/utils/models.ts";

// 用户注册
export const registerApi = (params: RegisterRequestModel) => {
    return http.post<ResultData>('/v1/user/account/register', params);
};
// 忘记密码
export const passwordApi = (params: PasswordRequestModel) => {
    return http.post<ResultData>('/v1/user/account/password', params);
};
// 用户登录
export const loginApi = (params: AuthRequestModel) => {
    return http.post<AuthModel>('/v1/user/account/login', params);
};

// 获取菜单列表及权限
export const getPolicyApi = () => {
    return http.post<MenuPermissionsModel>('/v1/user/profile/policy');
};

// 退出登录
export const logoutApi = () => {
    return http.post('/v1/user/profile/logout');
};

// 用户详情
export const getUserDetailApi = () => {
    return http.post<ResultData<UserModel>>('/v1/user/profile/detail');
};
// 更新用户
export const updateUserApi = (params: {
    nickname: string,
    avatar: string | Blob,
    mobile: string,
    description?: string
}) => {
    return http.post<ResultData<UserModel>>('/v1/user/profile/update', params);
};
// 更新邮箱
export const updateEmailApi = (params: { email: string, captcha: string }) => {
    return http.post<ResultData>('/v1/user/profile/email', params);
};
// 更新密码
export const updatePasswordApi = (params: { current: string, password: string, confirm: string }) => {
    return http.post<ResultData>('/v1/user/profile/password', params);
};
// 登录日志
export const getUserLoginLogApi = (params: { created_at?: [] }) => {
    return http.post<ResultPage<LoginLogModel>>('/v1/user/profile/login/log', params);
};
// 操作日志
export const getUserLoggerApi = (params: {}) => {
    return http.post<ResultPage<LoggerModel>>('/v1/user/profile/logger', params);
};
// 操作日志详情
export const getUserLoggerDetailApi = (params: { id: number }) => {
    return http.post<ResultData<LoggerModel>>('/v1/user/profile/logger/detail', params);
};
// 获取未读消息列表
export const getUserUnreadMsg = (params: { page: number, pageSize: number }) => {
    return http.post<ResultPage<MessageModel[]>>('/v1/user/message/unread', params);
};
// 获取未读消息列表
export const userReadMsg = (params: { uuid?: string }) => {
    return http.post<ResultPage<MessageModel[]>>('/v1/user/message/read', params);
};



